<template>
	<view class="reports">

		<view class="report">
			<!-- 顶部导航栏 -->

			<view class="report-user">
				{{visitorInfo.szCheckName}}
				<span class="line"></span>
				{{visitorInfo.szCheckSex}}
				<span class="line"></span>
				{{visitorInfo.szCheckAge}}
				<span class="line3" v-if="visitorInfo.szCheckTel===''?false:true"></span>
				{{visitorInfo.szCheckTel}}

			</view>
			<view class="health-status">

				<view class="status-title">
					<view class="report-content">
						健康状态:
						<span class="status-result">{{visitorInfo.szConstitutionName}}</span>
						<view class="report-time">
							<li>{{visitorInfo.szCreateTime}}
								<br />
								中医健康状态识别
							</li>
						</view>
					</view>
					<view class="report-img">
						<Progress :detectValue="visitorInfo.szScope"></Progress>
					</view>
				</view>
				<view class="health-judge">
					综合舌象分析属于亚健康状态，建议您一周后再次检测
				</view>
				<view class="report-chose">
					<view class="identify" @click='goTongue()'></view>
					<view class="analyze" @click="goHealth()"></view>
				</view>
			</view>

			<view class="report-plan">
				<view class="report-plan-title">建议调理方案</view>
				<view class="report-plans" v-for="item in drug_health_care[0].items">
					<view class="" style="display: flex;align-items: flex-end;justify-content: space-between;">
						<view class="" style="display: flex;">
							<image class="report-plan-img" :src="item.photo"></image>
							<view class="report-plan-text">{{item.name}}</view>
						</view>
						<view class="report-plan-up" @click="goShopping(item.jumpUrl)">查看详情</view>
					</view>
					<view class="report-plan-affect">
						<view class="report-plan-affect-text">{{item.desc}}</view>
					</view>
				</view>


			</view>
			<view class="other-plan">
				<p>其他调理方案</p>
				<view class="lists">
					<view class="list" @click="goCondition(1)">
						<image class="list-img"
							src="https://zhinengjiayi.oss-cn-chengdu.aliyuncs.com/home/detection_icon_food_default%404x.png">
						</image>
						<text class="list-text">饮食调养</text>
						<view class="icon">
							<uni-icons type="right" size="16"></uni-icons>

						</view>
					</view>
					<view class="list" @click="goCondition(2)">
						<image class="list-img"
							src="https://zhinengjiayi.oss-cn-chengdu.aliyuncs.com/home/detection_icon_motion_default%404x.png">
						</image>
						<text class="list-text">运动保健</text>
						<view class="icon">
							<uni-icons type="right" size="16"></uni-icons>

						</view>
					</view>
					<view class="list" @click="goCondition(3)">
						<image class="list-img"
							src="https://zhinengjiayi.oss-cn-chengdu.aliyuncs.com/home/detection_icon_pulse_default%404x.png">
						</image>
						<text class="list-text">穴位保健</text>
						<view class="icon">
							<uni-icons type="right" size="16"></uni-icons>

						</view>
					</view>
					<view class="list" @click="goCondition(4)">
						<image class="list-img"
							src="https://zhinengjiayi.oss-cn-chengdu.aliyuncs.com/home/detection_icon_music_default%404x.png">
						</image>
						<text class="list-text">情致调养</text>
						<view class="icon">
							<uni-icons type="right" size="16"></uni-icons>

						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import Progress from '@/components/progress/index.vue'
	import * as TongueApi from '@/api/tongue/tongue.js'
	import * as ProductApi from '@/api/product/product.js'
	export default {
		components: {
			Progress
		},
		onLoad(options) {
			this.$globalData.isRefresh = true;
			console.log(options.params)
			const paramsStr = options.params;
			const receivedParams = JSON.parse(paramsStr); // 将参数字符串解析为对象
			this.result = receivedParams.result
			this.reportid = receivedParams.reportid
			// console.log(this.reportid)
			// console.log(this.result)
			this.healthInfo()
		},
		onShow() {
			// this.healthInfo()
			// this.visitorInfo.szScope++;
		},
		data() {
			return {
				reportid: null, //舌诊报告ID
				responseData: {}, //拿到的总数据
				visitorInfo: {
					id: null,
					szCheckAge: '',
					szCheckBackImgUrl: '',
					szCheckName: '',
					szCheckSex: '',
					szCheckTel: '',
					szCheckTopImgUrl: '',
					szConstitutionName: '',
					szCreateTime: "",
					szScope: 30
				},
				tongueResultVo: {},
				result: {},
				drug_health_care: [],
				isProcessing: false
			};
		},

		methods: {
			goBack() {
				uni.$goBack();
			},
			//接收用户信息和健康指数
			async healthInfo() {
				const res = await TongueApi.getszReport(this.reportid)
				let responseData = res.data.data;
				this.drug_health_care = res.data.data.tongueResultVo.treatPlans[0].drug_health_care
				console.log(this.drug_health_care)
				// 使用解构赋值，将响应数据中的值直接赋给 addressData 对象的对应属性
				Object.keys(responseData).forEach(key => {
					if (key in this.visitorInfo) {
						this.visitorInfo[key] = responseData[key];
					}
				});
				console.log(this.visitorInfo)
			},
			getReport() {

				let reportInfo = clone(this.result);

				console.log(this.result)
			},
			goTongue() {
				uni.$toPage('/subpkg/AIdiagnos/TongueImageRecognition/TongueImageRecognition', {
					reportid: this.reportid
				})
			},
			goHealth() {
				uni.$toPage('/subpkg/AIdiagnos/HealthAnalysis/HealthAnalysis', {
					reportid: this.reportid
				})
			},
			goCondition(id) {
				console.log(id)
				uni.$toPage('/subpkg/AIdiagnos/ConditioningScheme/ConditioningScheme', {
					postid: id,
					reportid: this.reportid
				})
			},
			goShopping(jumpId) {
				this.goGoodsDetailVerify(jumpId)
			},
			async goGoodsDetailVerify(id) {
				// 如果正在执行，则直接返回
				if (this.isProcessing) return;

				// 设置为正在执行
				this.isProcessing = true;

				try {
					const res = await ProductApi.selectById(id);
					if (res.data.code === 320 || res.data.code === 321) {
						uni.$toPage('/subpkg/shoppingMall/productChangeHint/productChangeHint')
					} else if (res.data.code === 200) {
						uni.$toPage('/subpkg/shoppingMall/goods_detail/goods_detail', {
							goods_id: id
						})
					}
				} catch (error) {
					// 可以处理错误
				} finally {
					// 执行完成后，重置锁状态
					this.isProcessing = false;
				}
			},


		}
	}
</script>

<style lang="scss" scoped>
	.reports {
		// height: 100vh;
		width: 100vw;
		padding: 0;
		margin: 0;
		overflow-y: scroll;

		.report {

			margin-top: -120rpx;
			width: 100vw;
			background: url('https://zhinengjiayi.oss-cn-chengdu.aliyuncs.com/home/detection_img_bg_disabled%404x.png');
			background-repeat: no-repeat;
			background-size: 100%;
			display: flex;
			align-items: center;
			flex-direction: column;
			box-sizing: border-box;
			padding: 0 20rpx;


			.report-user {
				margin-top: 400rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				height: 48rpx;
				font-size: 32rpx;
				font-weight: 500;
				letter-spacing: 0rpx;
				line-height: 46.34rpx;
				color: rgba(255, 255, 255, 1);

				.line {
					display: inline-block;
					width: 1rpx;
					height: 25rpx;
					background-color: white;
					margin: 0 20rpx;
				}

				.line3 {
					display: inline-block;
					width: 1rpx;
					height: 25rpx;
					background-color: white;
					margin: 0 20rpx;
				}
			}

			// 健康状态
			.health-status {
				display: flex;
				justify-content: center;
				position: relative;
				flex-wrap: wrap;
				align-items: center;
				height: 624rpx;
				opacity: 1;
				border-radius: 14rpx;
				background: rgba(255, 255, 255, 0.7);
				backdrop-filter: blur(60rpx);
				margin-top: 5rpx;

				.status-title {
					width: 614rpx;
					display: flex;
					justify-content: space-between;
					/** 文本1 */
					font-size: 36rpx;
					font-weight: 700;
					color: rgba(30, 30, 32, 1);

					.report-content {
						// margin-left: 30rpx;
						margin-top: 36rpx;
					}

					.report-time {
						margin-top: 25rpx;
						width: 310rpx;
						height: 36rpx;
						opacity: 1;
						/** 文本1 */
						font-size: 24rpx;
						font-weight: 400;
						color: rgba(138, 138, 138, 1);

					}

					.status-result {
						margin-left: 17rpx;
						font-size: 36rpx;
						font-weight: 700;
						color: rgba(63, 209, 165, 1);

					}

					.report-img {}
				}

				.health-judge {
					width: 614rpx;
					height: 94rpx;
					/** 文本1 */
					font-size: 30rpx;
					font-weight: 500;
					letter-spacing: 0rpx;
					line-height: 46.34rpx;
					color: rgba(63, 209, 165, 1);
					text-align: justify;
					vertical-align: top;
				}

				.report-chose {
					width: 614rpx;
					display: flex;
					justify-content: space-around;

					.identify {
						width: 300rpx;
						height: 100rpx;
						border-radius: 14rpx;
						background: url('https://zhinengjiayi.oss-cn-chengdu.aliyuncs.com/home/%E8%92%99%E7%89%88%E5%88%86%E7%BB%842.png');
						background-size: 100%;
					}

					.analyze {
						width: 300rpx;
						height: 100rpx;
						opacity: 1;
						border-radius: 14rpx;
						background: url('https://zhinengjiayi.oss-cn-chengdu.aliyuncs.com/home/%E5%81%A5%E5%BA%B7%E5%88%86%E6%9E%90.png');
						background-size: 100%;
						margin-left: 20rpx;
					}
				}


			}

			// 建议方案
			.report-plan {
				margin-top: 20rpx;
				padding-bottom: 20rpx;
				width: 100%;

				.report-plan-title {
					font-size: 36rpx;
					font-weight: 400;
					letter-spacing: 0rpx;
					line-height: 52.12rpx;
					color: rgba(0, 0, 0, 1);
					text-align: left;
					vertical-align: top;
				}

				.report-plans {
					padding-bottom: 10rpx;
					margin-top: 20rpx;
					border-radius: 14rpx;
					background: rgba(255, 255, 255, 1);
					padding: 20rpx;

					.report-plan-img {
						width: 158rpx;
						height: 152rpx;
						border-radius: 8rpx;
						background: url(https://img.js.design/assets/img/653f6a68294562eb79fef1db.jpg#8140c6e6bad65a758e2dade3c4e0c4d6);
						background-size: 100%;
					}

					.report-plan-text {
						margin-left: 10rpx;
						font-size: 32rpx;
						font-weight: 400;
						letter-spacing: 0rpx;
						line-height: 46.34rpx;
						color: rgba(0, 0, 0, 1);
						text-align: left;
						vertical-align: top;


					}

					.report-plan-affect {
						padding: 10rpx;
						margin-top: 20rpx;
						border-radius: 14rpx;
						background: rgba(223, 161, 60, 0.13);

						.report-plan-affect-text {
							padding: 10rpx 10rpx;
							font-size: 28rpx;
							font-weight: 400;
							letter-spacing: 0rpx;
							line-height: 34.76rpx;
							color: rgba(0, 0, 0, 1);
						}
					}

					.report-plan-up {
						// position: absolute;
						padding: 5rpx 30rpx;
						border-radius: 14rpx;
						background: rgba(223, 161, 60, 1);
						font-size: 26rpx;
						font-weight: 500;
						letter-spacing: 0rpx;
						line-height: 54rpx;
						color: white;
						text-align: center;
						vertical-align: top;
					}

					.report-plan-up[plain] {
						border: 0;
					}

				}

				.report-plan2 {
					position: absolute;
					left: 28rpx;
					top: 1490rpx;
					height: 228rpx;
					opacity: 1;
					border-radius: 14rpx;
					background: rgba(255, 255, 255, 1);

				}
			}

			//其他建议方案
			.other-plan {
				width: 100%;
				margin-top: 20rpx;
				margin-bottom: 20rpx;

				p {
					margin: 20rpx 0;
					font-size: 36rpx;
					font-weight: 400;
					line-height: 52.12rpx;
					color: rgba(0, 0, 0, 1);
					text-align: left;
					vertical-align: top;
				}

				.lists {
					width: 100%;
					height: 394rpx;
					opacity: 1;
					border-radius: 14rpx;
					background: rgba(255, 255, 255, 1);

					.list {
						position: relative;
						height: 100rpx;

						.list-img {
							position: absolute;
							left: 28rpx;
							top: 28rpx;
							width: 30rpx;
							height: 32rpx;
							opacity: 1;
						}

						.list-text {
							position: absolute;
							left: 76rpx;
							top: 20rpx;
							width: 128rpx;
							height: 48rpx;
							opacity: 1;
							/** 文本1 */
							font-size: 32rpx;
							font-weight: 400;
							letter-spacing: 0rpx;
							line-height: 46.34rpx;
							color: rgba(0, 0, 0, 1);
							text-align: left;
							vertical-align: top;
						}

						.icon {
							position: absolute;
							margin-top: 17rpx;
							left: 640rpx;
						}


					}
				}
			}
		}

	}

	.reports::-webkit-scrollbar {
		display: none;

	}
</style>
